﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace Core.Models.Migrations
{
    public partial class changeTableName : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysPersons_SysOrgs_OrgId",
                table: "SysPersons");

            migrationBuilder.DropPrimaryKey(
                name: "PK_SysPersons",
                table: "SysPersons");

            migrationBuilder.DropPrimaryKey(
                name: "PK_SysOrgs",
                table: "SysOrgs");

            migrationBuilder.RenameTable(
                name: "SysPersons",
                newName: "SysPerson");

            migrationBuilder.RenameTable(
                name: "SysOrgs",
                newName: "SysOrg");

            migrationBuilder.RenameIndex(
                name: "IX_SysPersons_OrgId",
                table: "SysPerson",
                newName: "IX_SysPerson_OrgId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_SysPerson",
                table: "SysPerson",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_SysOrg",
                table: "SysOrg",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPerson_SysOrg_OrgId",
                table: "SysPerson",
                column: "OrgId",
                principalTable: "SysOrg",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysPerson_SysOrg_OrgId",
                table: "SysPerson");

            migrationBuilder.DropPrimaryKey(
                name: "PK_SysPerson",
                table: "SysPerson");

            migrationBuilder.DropPrimaryKey(
                name: "PK_SysOrg",
                table: "SysOrg");

            migrationBuilder.RenameTable(
                name: "SysPerson",
                newName: "SysPersons");

            migrationBuilder.RenameTable(
                name: "SysOrg",
                newName: "SysOrgs");

            migrationBuilder.RenameIndex(
                name: "IX_SysPerson_OrgId",
                table: "SysPersons",
                newName: "IX_SysPersons_OrgId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_SysPersons",
                table: "SysPersons",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_SysOrgs",
                table: "SysOrgs",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPersons_SysOrgs_OrgId",
                table: "SysPersons",
                column: "OrgId",
                principalTable: "SysOrgs",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
